With the development of information technologies, applications of multimedia technologies in networks are unprecedentedly developed, and video communication technologies, as important components of the multimedia technologies, are also greatly developed and widely applied. Because the amount of data of a video sequence is huge, a video is compressed before network transmission. Common video compression standards include the MPEG-2 (formulated by Moving Picture Experts Group, i.e. MPEG) standard for DVB, HDTV, and DVD, the MPEG-4 standard developed for a streaming media service in a network, the H.263 (formulated by International Telecommunication Union, i.e. ITU) standard proposed for videotelephony and video services, and the up-to-date H.264/AVC (formulated by Joint Video Team, i.e. JVT) standard and so on. In order to enable video data to be exchanged transparently between heterogeneous networks, between different access equipments, and between media data formats in different standards, transcoding between compressed video code streams becomes a hotspot research direction in digital video technology field.
Transcoding is a technology that a compressed video code stream in one standard and format is processed into a compressed video code stream in another standard and format which is more adapted to a certain specific application. Video transcoding performs end-to-end processing on a compressed video code stream, so that a compressed code stream after transcoding is more adapted to requirements of transmission channel bandwidth and a receiving end.
Main technologies for video transcoding can be categorized into code rate conversion, definition conversion, frame rate conversion, and syntax conversion. In a process of conversion, it is usually needed to perform code rate control. The code rate control is a flow control mechanism which avoids network congestion as much as possible, as well as fully utilizing network resources and guaranteeing video quality; and in a case that end-to-end time delay is as low as possible, the code rate control guarantees that a buffer neither overflows nor underflows. By allocating a target bit to a frame to be encoded, the code rate control further determines quantization parameters of the frame to be encoded, so as to control a code rate output by a transcoder. The code rate control can be categorized into two control methods, namely, frame layer code rate control and macro block layer code rate control.
The prior art provides a frame layer code rate control method which is adaptable in a process of transcoding from an MPEG-2 compression standard to an MPEG-4 compression standard. Information of bit stream is input at a decoding end of the transcoder. The information, such as image type, digits used by each frame, and average quantization parameters, is collected for performing code rate control on the output of a transcoder encoding end.
In the prior art, target bit rate ratio is calculated first. Target bit rate ratio of each frame is equal to: a ratio of a target bit N0j output by the frame to a bit Nij input by the frame, where j denotes the sequence number of the frame.rj=Noj/Nij   (1-1)
In a process of video encoding, a direct factor deciding digits used during encoding is a quantization parameter adopted at the time of quantizing obtained Discrete Cosine Transform (DCT) coefficients after performing DCT. The quantization parameter reflects a compression of details. If the quantization parameter is small, a majority of details are retained, and the code rate is higher. If the quantization parameter is great, partial details are discarded, the code rate is reduced, but image distortion is more serious, and quality is not high. That is to say, the quantization parameter is inversely proportional to the bit rate. In a process of transcoding, a basic method for code rate control is controlling a code rate of a code stream output by the transcoder by adjusting the quantization parameter.
The prior art utilizes the foregoing obtained target bit rate ratio, and establishes a code rate control model according to the following equation:QojNoj=QijNij   (1-2)
In the equation, Qij is a quantization parameter of an MPEG-2 video frame currently input by the transcoder, and Q0j is a target quantization parameter of an MPEG-4 video frame currently output by the transcoder.
A target quantization parameter output by the video frame which can be obtained from the equation 1-2 isQoj=Qij·Nij/Noj=Qij/rj   (1-3)
In order to make the obtained target quantization parameter to be more precise, a coefficient αkj is used to modify the obtained target quantization parameter, and the coefficient αkj is equal to: a ratio of accumulated complexity of a code stream output by the transcoder to that of a code stream input by the transcoder.
                              α          k          j                =                                            ∑                              j                =                0                                            k                -                1                                      ⁢                                          Q                o                j                            ·                              N                o                j                                                                        ∑                              j                =                0                                            k                -                1                                      ⁢                                          Q                i                j                            ·                              N                i                j                                                                        (                  1          ⁢                      -                    ⁢          4                )            
In the above equation, j denotes the sequence number of a frame, N0j is the actual encoding bit number of a jth output frame, and Nij is the actual encoding bit number of a jth input frame.
A target quantization parameter further obtained by utilizing the coefficient αkj isQ0j=αkj·Qij/rj   (1-5)
In order to enable the obtained target quantization parameter to be self-adaptively controlled by an actual encoding bit, a parameter βkj is introduced. The parameter is equal to a ratio of the actual accumulated bit number of an encoded output frame to the actual accumulated bit number of a corresponding input frame, divided by a ratio of the target bit number of a current output frame to the bit number of a current input frame.
                              β          k          j                =                                            ∑                              N                o                j                                                    ∑                              N                i                j                                              /                                    N              o              j                                      N              i              j                                                          (                  1          ⁢                      -                    ⁢          6                )            
The target quantization parameter finally obtained according to the parameter βk isQoj=βkj·αkj·Qij/rj   (1-7)
Encoding is performed according to the obtained target quantization parameter to acquire a code stream after performing the code rate control.
In a process of implementing the present invention, the inventors find that the prior art has at least the following problems.
A linear code rate control model adopted by the prior art is not applicable to a process of transcoding from MPEG-2/MPEG-4/H.261/H.263 to H.264, and an expected quantization parameter cannot be derived by the model, which results in that output code stream quality obtained by the transcoder according to the encoding of the quantization parameter is lower, and the code rate control is not accurate.